# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
# SPDX-License-Identifier: MIT

collect (PROJECT_LIB_SOURCES print.c)
collect (PROJECT_LIB_HEADERS xbasic_types.h)
collect (PROJECT_LIB_HEADERS xdebug.h)
collect (PROJECT_LIB_HEADERS xenv.h)
collect (PROJECT_LIB_HEADERS xenv_standalone.h)
collect (PROJECT_LIB_SOURCES xil_assert.c)
collect (PROJECT_LIB_HEADERS xil_assert.h)
collect (PROJECT_LIB_HEADERS xil_cache_vxworks.h)
collect (PROJECT_LIB_HEADERS xil_hal.h)
collect (PROJECT_LIB_HEADERS xil_io.h)
collect (PROJECT_LIB_HEADERS xil_macroback.h)
collect (PROJECT_LIB_SOURCES xil_mem.c)
collect (PROJECT_LIB_HEADERS xil_mem.h)
collect (PROJECT_LIB_SOURCES xil_printf.c)
collect (PROJECT_LIB_HEADERS xil_printf.h)
collect (PROJECT_LIB_SOURCES xil_testcache.c)
collect (PROJECT_LIB_HEADERS xil_testcache.h)
collect (PROJECT_LIB_SOURCES xil_testio.c)
collect (PROJECT_LIB_HEADERS xil_testio.h)
collect (PROJECT_LIB_SOURCES xil_testmem.c)
collect (PROJECT_LIB_HEADERS xil_testmem.h)
collect (PROJECT_LIB_HEADERS xil_types.h)
collect (PROJECT_LIB_SOURCES xil_util.c)
collect (PROJECT_LIB_HEADERS xil_util.h)
collect (PROJECT_LIB_SOURCES xplatform_info.c)
collect (PROJECT_LIB_HEADERS xplatform_info.h)
collect (PROJECT_LIB_HEADERS xstatus.h)
collect (PROJECT_LIB_SOURCES outbyte.c)
collect (PROJECT_LIB_SOURCES inbyte.c)
collect (PROJECT_LIB_HEADERS xmem_config.h)
collect (PROJECT_LIB_HEADERS xil_cryptoalginfo.h)
if(("${CMAKE_MACHINE}" STREQUAL "Versal") OR
   ("${CMAKE_MACHINE}" STREQUAL "VersalNet") OR
   ("${CMAKE_MACHINE}" STREQUAL "ZynqMP"))
collect (PROJECT_LIB_HEADERS pm_api_version.h)
endif()
string(FIND "${CMAKE_C_FLAGS}" "-flto" has_flto)
if ((${has_flto} EQUAL -1) AND
    ("${CMAKE_MACHINE}" STREQUAL "ZynqMP"))
if (NOT ${YOCTO})
add_subdirectory(clocking)
endif()
endif()
if (NOT ${YOCTO})
add_subdirectory(intr)
else()
collect (PROJECT_LIB_HEADERS sleep.h)
collect (PROJECT_LIB_HEADERS xparameters.h)
endif()
if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "microblaze") OR
   ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "microblazeel") OR
   ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "plm_microblaze") OR
   ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "pmu_microblaze"))
   collect (PROJECT_LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../xmicroblaze_g.c)
endif()
if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexa53-32") OR ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexa53") OR ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64") OR ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexa72") OR ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexa78"))
	collect (PROJECT_LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../xarmv8_g.c)
endif()
if(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexr5") OR
   ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm"))
   collect (PROJECT_LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../xcortexr5_g.c)
endif()

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexr52")
   collect (PROJECT_LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../xcortexr52_g.c)
endif()

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "cortexa9")
	collect (PROJECT_LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../xcortexa9_g.c)
endif()

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "microblaze_riscv")
	collect (PROJECT_LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../xmicroblaze_riscv_g.c)
endif()

if("${CMAKE_MACHINE}" STREQUAL "Versal")
add_subdirectory(versal)
endif()

if("${CMAKE_MACHINE}" STREQUAL "VersalNet")
add_subdirectory(versal_net)
endif()
